//
//  RecommendCell.m
//  WuJieLive
//
//  Created by 张瀚坤 on 2017/11/13.
//  Copyright © 2017年 zhk. All rights reserved.
//

#import "RecommendCell.h"

@implementation RecommendCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
    [self.collectionView registerNib:[UINib nibWithNibName:@"HomeRecommendCell" bundle:nil] forCellWithReuseIdentifier:@"cell"];
}

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
    return 10;
}

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
    return 10;
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return CGSizeMake(120,160);
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    HomeRecommendCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
    
    if (indexPath.row == 4) {
        cell.AllLabel.hidden = NO;
        cell.headerImageView.hidden = YES;
        cell.AllLabel.backgroundColor = [UIColor whiteColor];
        cell.AllLabel.layer.masksToBounds = YES;
        cell.AllLabel.layer.cornerRadius = 5;
        cell.AllLabel.layer.borderColor = TextLessImportColor.CGColor;
        cell.AllLabel.layer.borderWidth = 0.5;
        cell.detailLabel.text = @"";
        cell.priceLabel.text = @"";
    }else
    {
        if (self.dataArray.count > indexPath.row) {
            cell.headerImageView.hidden = NO;
            RecommendCellModel * model = [RecommendCellModel new];
            [model setValuesForKeysWithDictionary:self.dataArray[indexPath.row]];
            [cell bindDataWithRecommendModel:model];
        }
    }
    return cell;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 4) {
        
    }else
    {
        if (self.dataArray.count > indexPath.row) {
            RecommendCellModel * model = [RecommendCellModel new];
            [model setValuesForKeysWithDictionary:self.dataArray[indexPath.row]];
            if (self.pushGoodsBlock) {
                self.pushGoodsBlock(model.goods_id);
            }
        }
    }
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 5;
}

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 1;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
